package com.monizhuang;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class DbController {

    private static final Logger logger = LoggerFactory.getLogger(DbController.class);

    @Autowired
    private JdbcTemplate jdbcTemplate;
    @GetMapping("selectList")
    public List<Map<String, Object>> selectList(@RequestParam String sql) {
        return jdbcTemplate.queryForList(sql);
    }

    @GetMapping("selectOne")
    public Object selectOne(@RequestParam String sql) {
        return jdbcTemplate.queryForMap(sql);
    }

    @GetMapping("update")
    public int update(@RequestParam String sql) {
        return jdbcTemplate.update(sql);
    }

}